﻿using ServiceStack.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Redis
{
	class Program
	{
		static void Main(string[] args)
		{
			var client = new RedisClient("127.0.0.1", 6379);
			client.Set<int>("pwd", 1111);
			int pwd = client.Get<int>("pwd");
			Console.WriteLine(pwd);

			UserInfo userInfo = new UserInfo() { UserName = "zhangsan", UserPwd = "1111" };//</span>(底层使用json序列化 )    
			client.Set<UserInfo>("userInfo", userInfo);
			UserInfo user = client.Get<UserInfo>("userInfo");
			Console.WriteLine(user.UserName);

			List<UserInfo> list = new List<UserInfo>() { new UserInfo() { UserName = "lisi", UserPwd = "111" }, new UserInfo() { UserName = "wangwu", UserPwd = "123" } };
			client.Set<List<UserInfo>>("list", list);
			List<UserInfo> userInfoList = client.Get<List<UserInfo>>("list");

			foreach (var item in userInfoList)
			{
				Console.WriteLine(userInfo.UserName);
			}

			Console.ReadKey();
		}
		
	}
	public class UserInfo
	{
		public string UserName { get; set; }
		public string UserPwd { get; set; }
	}
}
